/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agtranscontinental.sisref.model;

import com.agtranscontinental.dgs001.dto.OrdenDto;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author ericson
 */
@Entity
@Table(name = "orden")
@NamedQueries({
    @NamedQuery(name = "Orden.findAll", query = "SELECT o FROM Orden o"),
    @NamedQuery(name = "Orden.findOdn", query = "SELECT o FROM Orden o WHERE o.anio=:anio and o.rgmen=:rgmen and o.adna=:adna and o.odn=:odn")
})
public class Orden implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Column(name = "anio")
    private Integer anio;
    @Column(name = "rgmen")
    private String rgmen;
    @Column(name = "adna")
    private String adna;
    @Column(name = "odn")
    private String odn;
    @Size(max = 150)
    @Column(name = "dccion")
    private String dccion;
    @Size(max = 150)
    @Column(name = "vssel")
    private String vssel;
    @Column(name = "eta")
    @Temporal(TemporalType.TIMESTAMP)
    private Date eta;
    @Column(name = "arrval_dte")
    @Temporal(TemporalType.TIMESTAMP)
    private Date arrvalDte;
    @Size(max = 150)
    @Column(name = "trde_term")
    private String trdeTerm;
    @Size(max = 150)
    @Column(name = "bl")
    private String bl;
    @Size(max = 150)
    @Column(name = "invce")
    private String invce;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "orden")
    private List<Serie> serieList;

    public Orden() {
    }

    public Orden(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getAnio() {
        return anio;
    }

    public void setAnio(Integer anio) {
        this.anio = anio;
    }

    public String getRgmen() {
        return rgmen;
    }

    public void setRgmen(String rgmen) {
        this.rgmen = rgmen;
    }

    public String getAdna() {
        return adna;
    }

    public void setAdna(String adna) {
        this.adna = adna;
    }

    public String getOdn() {
        return odn;
    }

    public void setOdn(String odn) {
        this.odn = odn;
    }

    public String getDccion() {
        return dccion;
    }

    public void setDccion(String dccion) {
        this.dccion = dccion;
    }

    public String getVssel() {
        return vssel;
    }

    public void setVssel(String vssel) {
        this.vssel = vssel;
    }

    public Date getEta() {
        return eta;
    }

    public void setEta(Date eta) {
        this.eta = eta;
    }

    public Date getArrvalDte() {
        return arrvalDte;
    }

    public void setArrvalDte(Date arrvalDte) {
        this.arrvalDte = arrvalDte;
    }

    public String getTrdeTerm() {
        return trdeTerm;
    }

    public void setTrdeTerm(String trdeTerm) {
        this.trdeTerm = trdeTerm;
    }

    public String getBl() {
        return bl;
    }

    public void setBl(String bl) {
        this.bl = bl;
    }

    public String getInvce() {
        return invce;
    }

    public void setInvce(String invce) {
        this.invce = invce;
    }

    public List<Serie> getSerieList() {
        return serieList;
    }

    public void setSerieList(List<Serie> serieList) {
        this.serieList = serieList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orden)) {
            return false;
        }
        Orden other = (Orden) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agtranconstinental.sisref.Orden[ id=" + id + " ]";
    }

    public OrdenDto toOrdenDto() {
        OrdenDto o = new OrdenDto();
        o.setId(id);
        o.setAdna(adna);
        o.setAnio(anio);
        o.setArrvalDte(arrvalDte);
        o.setBl(bl);
        o.setDccion(dccion);
        o.setEta(eta);
        o.setInvce(invce);
        o.setOden(odn);
        o.setRgmen(rgmen);
        o.setTrdeTerm(trdeTerm);
        o.setVssel(vssel);
        return o;
    }
}
